package com.bestcem.xm.common.core.config.log;

import ch.qos.logback.classic.filter.LevelFilter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.spi.FilterReply;

/**
 * @author zhenz
 * @date 2020/3/20 12:02
 */
public class SendLevelFilter extends LevelFilter {
    /**
     * 邮件发送开关
     */
    private boolean emailEnable;

    @Override
    public FilterReply decide(ILoggingEvent event) {

        if (!emailEnable) {
            return onMismatch;
        }

        return super.decide(event);
    }

    public boolean isEmailEnable() {
        return emailEnable;
    }

    public void setEmailEnable(boolean emailEnable) {
        this.emailEnable = emailEnable;
    }
}
